﻿#include <iostream>
#include <thread>

#include <zmq.hpp>
#include <spdlog/spdlog.h>

int main()
{
	zmq::context_t ctx;
	zmq::socket_t receiver = zmq::socket_t(ctx, ZMQ_PULL);
	receiver.connect("tcp://localhost:5557");

	zmq::socket_t sender = zmq::socket_t(ctx, ZMQ_PUSH);
	sender.connect("tcp://localhost:5558");

	while (true)
	{
		zmq::message_t task;
		receiver.recv(&task);

		std::string task_str((char*)task.data(), task.size());
		int workload = std::atoi(task_str.c_str());

		std::this_thread::sleep_for(std::chrono::milliseconds(workload));

		sender.send("", 0);
	}
}